<!-- 我的查询 -->

<template>
  <WebSearch class="ScrollList-MySearch">
    <template #btn>
      <BtnAdd :disabled="!inited" />
      <BtnsImport />
      <!-- <BtnsDeal /> -->
    </template>

    <ParamCheckbox bind="statusList" :dict="GETTER.DEVICE_STATUS" hasRight />
    <ParamInput :label="`${CORE.MAP.ASSET}编号 / ${CORE.MAP.ASSET}名称`" bind="keyword" />

    <template #super>
      <div>
        <SuperSelect label="设备品牌" bind="brandId" :dict="CORE.DICT.asset_brand" third />
        <SuperDateRange label="购置日期" bind="purchaseDateBegin, purchaseDateEnd" history string third />
        <SuperSelect label="供应商" bind="supplierId" :dict="supplier_selectDict" third />
      </div>

      <div>
        <SuperSelectMulti label="设备标签" bind="tagIdList" :dict="tagDict" third @change="changeTag" />
        <SuperTree :label="`所属${CORE.MAP.ORGAN}`" bind="organizationId" :dict="CORE.ORGAN.DICT" third />
        <SuperTree :label="`所在${CORE.MAP.REGION}`" bind="areaId" :dict="CORE.REGION.DICT" allName third />
      </div>
    </template>
  </WebSearch>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'MySearch',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [
    CORE.mixWeb(),
    CORE.mixSelect('supplier', 'supplier_'),
  ],

  /**
   * 组件导入 (Abc.vue + Abc/index.vue)
   */
  ...CORE.components(require.context('./', true, /vue$/)),

  /**
   * 计算属性 (慎用箭头函数)
   */
  computed: {
    /**
     * 设备标签字典
     */
    tagDict() {
      const { $root: { iot_tag_selectDict: tagDict } } = this
      return tagDict
    },
  },

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    /**
     * 切换标签
     */
    changeTag() {
      this.param.assetLabelDtos = this.param.tagIdList.map((tagId) => {
        const [labelId, labelName] = this.tag_selectDict.find(([id]) => tagId === id)
        return { labelId, labelName }
      })
    },
  },
}
</script>

<style lang="scss">
// @import '@admin/views/Maintain/Repair/RepairList/MySearch/index.scss';
</style>
